<template>
	<view class="profit">
		<!-- 信息 -->
		<view class="info flex-r-b-c">
			<view class="info_l">
				<view class="title">我的余额</view>
				<view class="money">¥ {{balance?balance:0}}元</view>
			</view>
			<view class="info_r" @tap.stop="withdrawalBtn">提现</view>
		</view>
		<!-- 提示 -->
		<view class="titleText">收益明细</view>
		<!-- 列表 -->
		<view class="listBox">
			<view class="list flex-r-b-c" v-for="(item,index) in list" :key="index">
				<view class="list_l">
					<view class="name">{{item.memo}}</view>
					<view class="time">{{item.createtime}}</view>
				</view>
				<view class="money" style="color: red;" v-if="item.money<0">{{item.money}}</view>
				<view class="money" style="color: forestgreen;" v-else>{{item.money}}</view>
			</view>
		</view>
		
		<!-- 提示栏 -->
		<view style="width: 100%; text-align: center; font-size: 28rpx; margin-top: 30rpx;">{{isText}}</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: 1,
				balance: '',
				list: [],
				isText: '',
				withdrawal_interdict:''
			};
		},
		onLoad() {
			
		},
		onShow() {
			this.page = 1
			this.balance = ''
			this.list = []
			this.isText = ''
			this.getProfitList()
		},
		methods: {
			// 获取收益中心列表
			getProfitList(){
				let that = this
				that.$api.profitList({
					page: that.page
				}).then(res => {
					that.withdrawal_interdict = res.data.data.withdrawal_interdict
					that.balance = res.data.data.all_money
					res.data.data.list.length == 0 ? that.isText = '暂无数据' : that.isText = ''
					that.list = that.list.concat(res.data.data.list.list)
					// console.log(that.list,'11')
				})
			},
			// 提现
			withdrawalBtn(){
				this.balance = this.balance == null ? 0: this.balance
				uni.navigateTo({
					url: `/pages/my/withdrawal/withdrawal?balance=${this.balance}&withdrawal_interdict=${this.withdrawal_interdict}`
				})
			}
		},
		onReachBottom() {
			let that = this
			if(that.isText == ''){
				that.page = that.page + 1
				that.getProfitList()
			}
		}
	}
</script>

<style lang="less">
	.profit{
		width: 100vw;
		.info{
			width: 100%;
			height: 158rpx;
			padding: 30rpx;
			.info_l{
				width: 50%;
				font-size: 28rpx;
				font-weight: 400;
				color: #474747;
				text-align: center;
				.money{
					font-size: 32rpx;
					font-weight: 500;
					color: #000;
					margin-top: 10rpx;
				}
			}
			
			.info_r{
				width: 150rpx;
				height: 62rpx;
				line-height: 62rpx;
				text-align: center;
				border-radius: 62rpx;
				background-color: #000;
				color: #fff;
				font-size: 24rpx;
				font-weight: 400;
			}
			
		}
		
		.titleText{
			width: 100%;
			height: 80rpx;
			line-height: 80rpx;
			background: #F9F9F9;
			font-size: 28rpx;
			font-weight: 400;
			color: #474747;
			padding-left: 30rpx;
		}
		
		.listBox{
			width: 100%;
			padding: 0rpx 30rpx;
			.list{
				width: 100%;
				height: 158rpx;
				padding: 30rpx 0rpx;
				border-bottom: 1px solid #EFEFEF;
				.list_l{
					font-size: 28rpx;
					font-weight: 400;
					color: #000;
					.time{
						margin-top: 20rpx;
					}
				}
				.money{
					font-size: 32rpx;
					font-weight: 500;
				}
			}
		}
		
		
	}
</style>
